import logging
import redis
import flask_sqlalchemy

class Config(object):
    # 调试模式
    DEBUG = True

    # 添加session密钥
    SECRET_KEY = "jklasdafjlkads"

    # 数据库配置
    SQLALCHEMY_DATABASE_URI = "mysql+pymysql://root:gm931227@localhost:3306/information15"
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    # 视图函数结束，失去连接的时候，会自动提交
    SQLALCHEMY_COMMIT_ON_TEARDOWN = True

    # redis的配置
    REDIS_HOST = "127.0.0.1"
    REDIS_PORT = 6379

    # session配置，session
    SESSION_TYPE = "redis"  # 指定session存储类型
    SESSION_USE_SIGNER = True  # 签名存储
    SESSION_PERMANENT = False  # 设置Session是否需要过期
    SESSION_REDIS = redis.StrictRedis(host=REDIS_HOST, port=REDIS_PORT)
    PERMANENT_SESSION_LIFETIME = 80808
    LEVEL = logging.DEBUG



# 开发模式
class DeveloperConfig(Config):
    pass


# 生产模式
class ProductConfig(Config):
    DEBUG = False
    LEVEL = logging.ERROR


# 测试模式
class TestingConfig(Config):
    TESTING = True


# 提供外界的统一访问方式
config_dict = {
    "develop": DeveloperConfig,
    "production": ProductConfig,
    "test": TestingConfig
}

